<template>
  <div>
    <div>
      <el-tag>
        {{ title }}
      </el-tag>
    </div>
    <div>
      <slot></slot>
    </div>
    <div>
      <el-button @click="success" type="primary">确定</el-button>
      <el-button @click="reset">重置</el-button>
    </div>
  </div>
</template>

<script>
import { addIdentity, addAuthorityApi } from "@/api/user";
export default {
  props: {
    title: {
      type: String,
    },
    api: {
      type: String,
    },
    prop: {
      type: Object,
    },
  },
  methods: {
    success() {
      const { identity_text, 
              api_authority_text, 
              api_authority_url,
              api_authority_method } = this.prop;
      switch (this.api) {
        case "/identity/edit":
          addIdentity({
            identity_text,
          }).then((res) => {});
          break;
        case "/user/authorityApi/edit":
          addAuthorityApi({
            api_authority_text,
            api_authority_url,
            api_authority_method,
          }).then((res) => {});
          break;
        default:
          break;
      }
    },
    reset() {
        this.$emit('reset', {})
    }
  },
};
</script>

<style>
</style>